package controller;

import csel.controller.enums.ActionEnum;
import csel.controller.events.Event;
import csel.controller.decoders.EventDecoder;
import csel.controller.dispatchers.Dispatcher;
import csel.model.GameCommand;
import csel.model.Invoker;

public class TestThatEventDecoderShitSon
{
	public static void main(String[] ags) throws InterruptedException
	{
		Dispatcher disp = new Dispatcher(new Thing());
		disp.startDispatcher();
		
		Decoder decoder = new Decoder( disp );
		Thread coolThread = new Thread( decoder );
		coolThread.start();
		
		decoder.registerEvent( new EventThinger() );
		decoder.registerEvent( new EventThinger() );
		decoder.registerEvent( new EventThinger() );
		decoder.registerEvent( new EventThinger() );
		
		Thread.sleep( 1000 );
		coolThread.interrupt();
		disp.stopDispatcher();
	}
	
	private static class Decoder extends EventDecoder<EventThinger>
	{
		public Decoder(Dispatcher disp)
		{
			super(disp);
			// TODO Auto-generated constructor stub
		}
		@Override
		protected GameCommand parseEvent(Event event)
		{
			if( event.getActionEnum() == ActionEnum.CHANGE_SUBVIEW )
				return new GC();
			else 
				return null;
		}
	}
	
	private static class GC implements GameCommand
	{
		public void execute()
		{
			System.out.println("I'm a big fucking game command!!");
		}
	}
	
	private static class Thing implements Invoker
	{
		public void accept(GameCommand gc)
		{
			gc.execute();
		}
	}
	
	private static class EventThinger implements Event
	{
		public ActionEnum getActionEnum()
		{
			return ActionEnum.CHANGE_SUBVIEW;
		}
	}
	
	
}
